﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace TermitesMagnets
{
    class Level0 : Level
    {
        private static int numberOfColors = 1;
        private const int numberOfTermitesPerColor = 300;


        public Level0(GameplayScreen game) : base(game)
        {
        }

        public override void Restart()
        {
            base.Restart();
            colors = new List<Color>(){Color.Red};
            magnetsColors = new List<Color>() { Color.IndianRed};
            targets = new List<TargetRect>();
            HumanTargets.Add(new TargetRect(this, Color.Red, 0,
                (int)(numberOfTermitesPerColor), new Vector2(20, 20), new Vector2(0, 0)));
            targets.AddRange(AiTargets);
            targets.AddRange(HumanTargets);
            board.AddObstacle(new Rectangle(200, 0, 20, 50));

            board.AddObstacle(new Rectangle(200, 100, 20, 50));
            /*
            for (int x = 200; x < 300; x++)
            {
                for (int y = 0; y < board.Rows; y+=50)
                {
                    for(int j=0;j<20;j++)
                        board.Occupy(x, y+j);
                }
            }
            */

            termites = new List<Termite>();

            for (int i = 0; i < numberOfColors; i++)
            {
                for (int j = 0; j < numberOfTermitesPerColor; j++)
                {
                    int col,row;
                    do
                    {
                        col = Game1.Rand.Next(Board.Cols);
                        row = Game1.Rand.Next(Board.Rows);
                    }while(!board.Occupy(col,row));
                    Vector2 position = new Vector2(col,row); 
                    termites.Add(new Termite(Game1.GlobalGame,this, position, colors[i], i));
                }
            }

            magnets = new List<Magnet>();
            for (int i = 0; i < numberOfColors; i++)
			{
                Vector2 position = new Vector2(Game1.Rand.Next(Board.Cols), Game1.Rand.Next(Board.Rows));
                magnets.Add(new Magnet(Game1.GlobalGame, this, position, magnetsColors[i], i));
			}


            pwus = new List<Pwu>();
            for (int i = 0; i < numberOfColors; i++)
            {
                Vector2 position = new Vector2(Game1.Rand.Next(Board.Cols), Game1.Rand.Next(Board.Rows));
                pwus.Add(new Pwu0(Game1.GlobalGame, this, position, 0));

            }

        }
    }
}
